import { Tip } from 'beeshell';

export default function requestCheck(response, callback, navigation) {
  if (!response) {
    Tip.show('请求错误');
    return;
  }
  const { status, data } = response;
  if (status === 401) {
    Tip.show('令牌不合法！');
    navigation.navigate('Auth');
  } else if (status !== 200) {
    Tip.show('网络请求错误！');
  } else {
    const { data: d, status: s, message } = data;
    if (s !== '200') {
      Tip.show(message);
    } else {
      callback(d);
    }
  }
}
